<template>
<div class="notice-banner-item">
  <div class="info">
    <span class="icon cuifont" :class="icon" :style="{color: item.colour}" style="margin-right: 16px"></span>
    <div class="text">
      <div class="notice-title">{{item.paramsValue.bannerTitle}}</div>
      <div class="notice-text" v-html="item.paramsValue.bannerContent"></div>
    </div>
  </div>
  <el-button size="mini" @click="close">Close</el-button>
</div>
</template>

<script>
export default {
  name: "notice-banner-item",
  props: {
    item: {
      type: Object,
    },
    index: {
      type: Number
    }
  },
  computed: {
    icon () {
      let icon = ''
      switch (this.item.type) {
        case 'Info':
          icon = 'icon_info_circle_fill'
          break
        case 'Alert':
          icon = 'icon_warning'
          break
        case 'Notification':
          icon = 'icon_alert_urgent'
          break
        case 'Update Released':
          icon = 'icon_textbox'
          break
        default:
          icon = 'icon_info_circle_fill'
      }
      return icon
    }
  },
  methods: {
    close () {
      this.$emit('close', this.item)
    }
  }
}
</script>

<style scoped lang="scss">
p {
  margin: 0;
  padding: 0;
}
.notice-banner-item {
  height: 70px;
  background: #fff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 0 16px;
  .info {
    display: flex;
    align-items: center;
    max-width: 80%;
    .text {
      width: 100%;
      display: flex;
      flex-direction: column;
      .notice-title {
        margin-bottom: 4px;
      }
      .notice-text {
        word-wrap: break-word;
        width: 100%;
        overflow:hidden;
        text-overflow:ellipsis;
        display:-webkit-box;
        -webkit-box-orient:vertical;
        -webkit-line-clamp:2;
        font-size: 12px;
        color: rgba(0, 0, 0, 0.45);
        p {
          padding: 0;
          margin: 0 !important;
        }
      }
    }
    .icon {
      font-size: 34px;
    }
  }
}
</style>